<%-- 
    Document   : FinalPlanReport
    Created on : Dec 10, 2009, 11:57:32 PM
    Author     : zhi
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="Service.*, javabeans.*, java.util.*"%>
<%!
    List<Event> eventList;
    String planname;
    String planDescription;
    Member member;
    List<Member> memberList;
%>

<%
    int type = Integer.parseInt(request.getParameter("type"));
    
    if(type == 1) {
        int planid = Integer.parseInt(request.getParameter("planid"));
        System.out.println("planid in final scheduel:" + planid);
        PlanService ps = new PlanServiceImpl();
        Plan plan = ps.getPlan(planid);
        System.out.println(plan.getPlanname());
        eventList = plan.getEvents();
        System.out.println("event list size: " + eventList.size());
        planname = plan.getPlanname();
        planDescription = plan.getPlandescript();
        member = plan.getMember();
    } else if(type == 2) {
        int groupplanid = Integer.parseInt(request.getParameter("groupplanid"));
        GroupPlanService gps = new GroupPlanServiceImpl();
        GroupPlan groupplan = gps.getGroupPlan(groupplanid);
System.out.println("groupplanid in final scheduel:" + groupplanid);
System.out.println(groupplan.getGroupplanname());
        eventList = gps.getGroupEventList(groupplanid);
System.out.println("event list size: " + eventList.size());
        planname = groupplan.getGroupplanname();
        planDescription = groupplan.getPlandescript();
        memberList = groupplan.getGroupmembers();
System.out.println("member list size: " + memberList.size());
System.out.println(memberList);

    }
    FinalScheduleService fss = new FinalScheduleServiceImpl();
    fss.sortEventList(eventList);
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Trip Schedule</title>
        <link rel="stylesheet" type="text/css" href="./css/final-schedule.css" />
    </head>

<body>

<table width="1000" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="1000" height="928" align="left" valign="top" background="image/finalschedule/bigtop.gif" style="background-repeat:no-repeat; ">
	<div id="Layer1" style="position:relative; width:180px; height:115px; z-index:3; left: 40px; top: 460px;">
        <table width="166" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="166" height="25" align="left" valign="top"><img src="image/finalschedule/planName.gif" width="83" height="19"></td>
          </tr>
          <tr>
            <td height="25" align="left" valign="top">
                <input name="planName" type="text" value="<%= planname%>" size="23">
            </td>
          </tr>
          <tr>
            <td height="25" align="left" valign="top"> <img src="image/finalschedule/description.gif" width="83" height="19"></td>
          </tr>
          <tr>
            <td  align="left" valign="top">
              <textarea name="description" cols="21" rows="10"><%= planDescription%></textarea>
            </td>
          </tr>
          <tr>
            <td height="25" align="left" valign="bottom"> <img src="image/finalschedule/members.gif" width="85" height="19"></td>
          </tr>
          <tr>
            <td height="160"  align="left" valign="bottom">
              <textarea name="members" cols="21" rows="7">
                    <%
                        if(type == 1) out.print(member.getEmail());
                        else {
                            for(int j=0;j<memberList.size();j++) {
                                Member member = memberList.get(j);
                                if(member!=null)
                                    out.println(member.getEmail());
                            }
                        }
                    %>
              </textarea>
            </td>
          </tr>
        </table>
        </div>
        <div id="calendrier">
            <table width="670" border="0" cellspacing="0" cellpadding="0" style="position:absolute; left:279px; top: 467px; ">
                <%
                    Event event;
                    String date = "";
                    for(int i=0;i<eventList.size();i++) {
                        if(i==5) break;
                        event = eventList.get(i);
                        String date_temp = event.getEventdate();
                        if(date_temp.equals(date)==false) {
                %>
                            <tr>
                                <td class="head2" width="91" height="28" ><%=event.getEventdate()%></td>
                                <td class="head" width="70" height="28" >&nbsp;</td>
                                <td class="head" width="509" height="28">&nbsp;</td>
                            </tr>
                <%
                            date = event.getEventdate();
                        }
                %>      
                <tr>
                    <td width="91" height="91" rowspan="2" class="time"><%=event.getEventtime()%></td>
                    <td width="70" height="50" class="content"><img src="image/icons/<%=event.getType()%>.gif" width="50" height="50"></td>
                    <td width="509" height="70" rowspan="2" class="content">
                         <%=event.getEventdescript()%>
                    </td>
                </tr>
                <tr>
                    <td height="20" class="content"><%=event.getEventname()%></td>
                </tr>
                <tr>
                    <td height="7" colspan="3"><img src="image/finalschedule/line.gif" width="665" height="6"></td>
                </tr>
                <%
                    }
                %>
          </table>
    </div>
	</td>
  </tr>
  <tr>
    <td><img src="image/finalschedule/bigtop_r2_c1.gif" width="1000" height="89"></td>
  </tr>
</table>

</body>
</html>
